﻿@inject MessageService _message
@inject ConfirmService _confirmService


<Divider>Buttons</Divider>

<Space>
    <SpaceItem>
        <Button OnClick="@(async ()=> { await ShowConfirm(ConfirmButtons.OK); })">OK</Button>
    </SpaceItem>
    <SpaceItem>
        <Button OnClick="@(async ()=> { await ShowConfirm(ConfirmButtons.OKCancel); })">OKCancel</Button>
    </SpaceItem>
</Space>

<br />
<br />

<Space>
    <SpaceItem>
        <Button OnClick="@(async ()=> { await ShowConfirm(ConfirmButtons.YesNo); })">YesNo</Button>
    </SpaceItem>

    <SpaceItem>
        <Button OnClick="@(async ()=> { await ShowConfirm(ConfirmButtons.YesNoCancel); })">YesNoCancel</Button>
    </SpaceItem>
</Space>

<br />
<br />

<Space>
    <SpaceItem>
        <Button OnClick="@(async ()=> { await ShowConfirm(ConfirmButtons.RetryCancel); })">RetryCancel</Button>
    </SpaceItem>
    <SpaceItem>
        <Button OnClick="@(async ()=> { await ShowAbortRetryIgnore(); })">AbortRetryIgnore</Button>
    </SpaceItem>

</Space>

<Divider>Icon</Divider>

<Space>
    <SpaceItem>
        <Button OnClick="@(async ()=> await ShowConfirmIcon(ConfirmIcon.Error))">Error</Button>
    </SpaceItem>
</Space>
<Space>
    <SpaceItem>
        <Button OnClick="@(async ()=> await ShowConfirmIcon(ConfirmIcon.Info))">Info</Button>
    </SpaceItem>
</Space>   
 <Space>
    <SpaceItem>
        <Button OnClick="@(async ()=> await ShowConfirmIcon(ConfirmIcon.None))">None</Button>
    </SpaceItem>
</Space>   
 <Space>
    <SpaceItem>
        <Button OnClick="@(async ()=> await ShowConfirmIcon(ConfirmIcon.Question))">Question</Button>
    </SpaceItem>
</Space>  
  <Space>
    <SpaceItem>
        <Button OnClick="@(async ()=> await ShowConfirmIcon(ConfirmIcon.Success))">Success</Button>
    </SpaceItem>
</Space>  
  <Space>
    <SpaceItem>
        <Button OnClick="@(async ()=> await ShowConfirmIcon(ConfirmIcon.Warning))">Warning</Button>
    </SpaceItem>
</Space>

@code{

    private async Task ShowConfirm(ConfirmButtons confirmButtons)
    {
        var content = "Here is a blocking confirm, you can get OK or cancel button is click";
        var title = "Info";
        var confirmResult = await _confirmService.Show(content, title, confirmButtons);

        var _ = _message.Info($"{confirmResult} button is clicked", 2);
    }

    private async Task ShowConfirmIcon(ConfirmIcon confirmIcon)
    {
        var content = "You can set different icons";
        var title = confirmIcon.ToString();
        var confirmResult = await _confirmService.Show(content, title, ConfirmButtons.OK, confirmIcon);

        var _ = _message.Info($"{confirmResult} button is clicked", 2);
    }

    private async Task ShowAbortRetryIgnore()
    {
        var content = "Here is from ConfirmService, you can get which button is click from result";
        var title = "Info";
        var confirmResult =
            await _confirmService.Show(
                content,
                title,
                ConfirmButtons.AbortRetryIgnore,
                ConfirmIcon.Error,
                new ConfirmButtonOptions()
                {
                    Button1Props = new AntDesign.ButtonProps()
                    {
                        Type = AntDesign.ButtonType.Dashed
                    },
                    Button2Props = new AntDesign.ButtonProps()
                    {
                        Type = AntDesign.ButtonType.Primary,
                        Disabled = true
                    }
                }
            );

        var _ = _message.Info($"{confirmResult} button is clicked", 2);
    }
}
